package com.transfiguro.datamodel.javamodels;

import japa.parser.ast.expr.Expression;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * This class defines a variable. In any class or method, when a variable is encountered, an instance
 * of {@link Variable} will be created
 */
public class Variable {
    private final Logger logger = LoggerFactory.getLogger(Variable.class);

    private String variableName;
    private int accessModifier;
    private boolean isConvertible;
    private boolean hasValue;
    private String type; //String type??? Should types be defined separately???
    private Expression value;

    public String getVariableName() {
        return variableName;
    }

    public void setVariableName(final String variableName) {
        this.variableName = variableName;
    }

    public int getAccessModifier() {
        return accessModifier;
    }

    public void setAccessModifier(final int accessModifier) {
        this.accessModifier = accessModifier;
    }

    public boolean isConvertible() {
        return isConvertible;
    }

    public void setConvertible(final boolean convertible) {
        isConvertible = convertible;
    }

    public boolean isHasValue() {
        return hasValue;
    }

    public void setHasValue(final boolean hasValue) {
        this.hasValue = hasValue;
    }

    public String getType() {
        return type;
    }

    public void setType(final String type) {
        this.type = type;
    }

    @Override
    public String toString() {
        StringBuilder builder = new StringBuilder();
        builder.append("Variable").append('\n')
                .append("Name: ").append(variableName).append('\n')
        .append("Type: ").append(type);
        return  builder.toString();
    }

    public Expression getValue() {
        return value;
    }

    public void setValue(final Expression value) {
        this.value = value;
    }
}
